#include "Quick_Sort.h"
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

void Quick_Sort::randomizeArray()
{
	srand((unsigned)time(0));
	long rand_num = 0;
	for (int i = 0; i < SIZE; i++)
	{
		rand_num = (rand()%1000) * (rand()%1000) + 1;
		Array[i] = rand_num;
	}
}

void Quick_Sort::quickSort(long arr[], long Left, long Right)
{
	L = Left;
	R = Right;
	pivot = Array[Right];

	while (L <= R)
	{
		while(Array[L] < pivot)
		{
			L++;
		}
		while(Array[R] > pivot)
		{
			R--;
		}
		if (L <= R)
		{
			swap = Array[L];
			Array[L] = Array[R];
			Array[R] = swap;
			L++;
			R--;
		}
	}

  if (Left < R)
      quickSort(Array, Left, R);

  if (Right > L)
	  quickSort(Array, L, Right);
}

void Quick_Sort::print()
{
	for(int i = 0; i < SIZE; i++)
	{
		cout << Array[i] << " ";
	}

	cout << endl;
}